package com.mail1.service;

import com.mail1.model.Mail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;


/**
 * @author vito
 * @version 1.0
 */
@Service
public class MailService {
    @Autowired
    JavaMailSender javaMailSender;
    public void sendSimpleMailMessage(Mail mail) {
        System.out.println(mail);
        // 封装simpleMailMessage
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(mail.getFrom());
        simpleMailMessage.setTo(mail.getTo());
        simpleMailMessage.setCc(mail.getCc());
        simpleMailMessage.setSubject(mail.getSubject());
        simpleMailMessage.setText(mail.getContent());
        // 发送邮件
        javaMailSender.send(simpleMailMessage);
    }
}
